import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';

class CustomLoadWidget extends StatefulWidget {
  final CancelFunc? cancelFunc;
  String? _loadText = "Loading";

  CustomLoadWidget({Key? key, String? loadText = "Loading", this.cancelFunc}) : super(key: key) {
    _loadText = loadText;
  }

  @override
  _CustomLoadWidgetState createState() => _CustomLoadWidgetState();
}

class _CustomLoadWidgetState extends State<CustomLoadWidget> with SingleTickerProviderStateMixin {
  late AnimationController _animationController;

  @override
  void initState() {
    super.initState();
    _animationController = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Card(
      child: Padding(
        padding: const EdgeInsets.all(0.0),
        child: Container(
          height: 90,
          width: 90,
          child: Stack(
            alignment: Alignment.bottomCenter,
            children: <Widget>[
              Container(alignment: Alignment.center, child: CircularProgressIndicator(color: Colors.black, strokeWidth: 4)),
              Positioned(
                bottom: 5,
                child: Text(
                  widget._loadText!,
                  style: TextStyle(fontSize: 11, color: Colors.black),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
